﻿using System;
using System.Collections;

namespace Framework.Unity
{
    public static class Container
    {
        public static readonly IContainer Empty = new EmptyContainer();

        private static IContainer _currentContainer = Empty;

        public static void InitializeWith(IContainer concreteContainer)
        {
            _currentContainer = concreteContainer ?? Empty;
        }

        public static object GetA(Type contract)
        {
            return _currentContainer.GetA(contract);
        }

        public static object GetA(Type contract, IDictionary parameters)
        {
            return _currentContainer.GetA(contract, parameters);
        }

        public static TContract GetA<TContract>()
        {
            return _currentContainer.GetA<TContract>();
        }

        public static TContract GetA<TContract>(IDictionary arguments)
        {
            return _currentContainer.GetA<TContract>(arguments);
        }

        public static void Release(object service)
        {
            _currentContainer.Release(service);
        }

        public static IContainer InnerContainer
        {
            get { return _currentContainer; }
        }
    }
}
